using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Drawing;
using System.Threading;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
using Dimok.Data;
using Dimok.Data.Database;
using Dimok.Exceptions;
using Data;

namespace Dimok.Aspx.Manager.Application{
	/// <summary>
	/// Summary description for WebForm1.
	/// </summary>
	public partial class Application_New : Page_AL{

		#region ========== Members ==========
		public const string UPDATE_APPL = "UpdateApplInfo";
		#endregion =============================

		#region ========== Web Controls Declarations ===========

		
		protected HtmlSelect selHouseHolds;

		
		#endregion =============================================
	
		delegate string GetTagsDs(object id);
		protected void Page_Load(object sender, System.EventArgs e){
			try{
				if( !uox.hasApplID ){// If no ApplID assume that new applicant is required
					int aID = uox.AddApplicant(uox.menuID);
					Context.Response.Redirect("/manager/menu/showapplicant.aspx?"+UOX.APPL_ID_PARAM+"="+aID);
					return;
				}
				dsLoanInfo.Selected += new ObjectDataSourceStatusEventHandler(dsLoanInfo_Selected);
				//SQL.SELECT(selDealers,uox.db,SQL.Dealers_V,"Name","ID");
				//SQL.SELECT(selSalesPersons,uox.DealerSalesPersons(),"Name","ID");

				//car.VIN = uox.LoanInfo.VIN;
				//SQL.BindSelect(selHouseHolds,SQL.ExecuteDatasetEx(uox.db,"SELECT * FROM ts_HouseHoldType"),"Name","ID");

			}catch(ThreadAbortException){
			}catch(Exception exc){throw new ClientException(exc);}
		}
		protected void phBorrowers_Load(object sender, EventArgs e) {
			PlaceHolder phBorrowers = sender as PlaceHolder;
			byte borrowersCount = uox.LoanInfo.BorrowersCount();
			for (byte b = 0; b < borrowersCount; b++) {
				Manager.Lib.Controls.Borrower ctlBorr = (Manager.Lib.Controls.Borrower)this.LoadControl("/manager/lib/controls/Borrower.ascx");
				ctlBorr.BorrowerPosition = b;
				phBorrowers.Controls.Add(ctlBorr);
			}
			Manager.Lib.Controls.Borrower ctlBorr0 = (Manager.Lib.Controls.Borrower)this.LoadControl("/manager/lib/controls/Borrower.ascx");
			ctlBorr0.BorrowerPosition = borrowersCount;
			phBorrowers.Controls.Add(ctlBorr0);
		}

		void dsLoanInfo_Selected(object sender, ObjectDataSourceStatusEventArgs e) {
			XmlLoanInfo.InnerHtml = SQL.XmlInnerText(((DataView)e.ReturnValue).Table);
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}

		protected void selLoanStatus_DataBound(object sender, EventArgs e) {
			((ListBox)sender).Rows = ((ListBox)sender).Items.Count;
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		///this.Load += new System.EventHandler(this.Page_Load);
		private void InitializeComponent(){
		}
		#endregion

	}
	class A : Page {
	}
}
